import {createStore,applyMiddleware} from 'redux'
import reducer from '../reducer'
import thunk from 'redux-thunk'
import logger from 'redux-logger'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

const persistConfig = {
    key: 'root',
    storage: storage,
  }
const persistedReducer = persistReducer(persistConfig, reducer)
export default () => {
    let store = createStore(persistedReducer,applyMiddleware(thunk,logger))
    let persistor = persistStore(store)
    return { store, persistor }
  }
